<?
	global $kam_admin, $FullUrl, $arr, $table_edit, $elements, $config_xml_list, $values;
    $edit_url = 'admin-pro.html?do='.$table_edit.'&act=edit_full&id=';
    $delete_url = 'admin-pro.html?do='.$table_edit.'&act=del&id=';
    $deletelist_url = 'admin-pro.html?do='.$table_edit.'&act=dellist';
    $showlist_url = 'admin-pro.html?do='.$table_edit.'&act=show';
    $hidelist_url = 'admin-pro.html?do='.$table_edit.'&act=hide';
    $changeactive_url='admin-pro.html?do='.$table_edit.'&&act=changeactive&page='.(isset($_GET['page'])?$_GET['page']:'1').'&id=';
    $changeorder_url = 'admin-pro.html?do='.$table_edit.'&act=order';
?>
<?
    $page_url = isset($_GET['page'])?'&page='.$_GET['page']:'';
    $trans_form = ($act=='add_full')?'addsm_full':(($act=='edit_full')?'editsm_full':'');
    $trans_url = 'admin-pro.html?do='.$table_edit.'&act='.$trans_form.$page_url;

?>
<!-- Alternative Content Box Start -->
<?
	//print_r($arr);
    //echo $config_xml_list[30];
?>

<div class="contentcontainer">
  <div class="headings altheading">
    <h2>List Questions</h2>
  </div>
  <form name="frmEdit" id="frmEdit" method="post" action="<?=$trans_url?>" onsubmit="return confirm('Are You Sure?');">
    <div class="contentbox">
      <table width="100%">
        <thead>
          <tr>
            <td>Alias </td>
            <td><input type="text" id="alias" class="inputbox" name="alias" value="<?=$values['alias']?>"/></td>
          </tr>
          <tr>
            <td>Values </td>
            <td><input type="text" id="values" class="inputbox" name="values" value="<?=$values['values']?>"/></td>
            <td><input type="button" value="Tạo Values" class="btn" onclick="CheckCreate(); return false;"/></td>
          </tr>
          <tr>
            <td>Type Group</td>
            <td><select id="type" name="type">
                <option value="1" <?=$values['type']=='1'? 'selected="selected"': ''?>>List</option>
                <option value="2" <?=$values['type']=='2'? 'selected="selected"': ''?>>Edit</option>
              </select></td>
          </tr>
          <tr>
            <th>No.1</th>
            <th>Name</th>
            <th>Type</th>
            <th><input name="" type="checkbox" value="" onclick="checkAll();return false;" id="all" checked="checked"/>
              <input name="" type="checkbox" value="" onclick="checkAll2();return false;" id="all2"/></th>
            <th>Edit</th>
          </tr>
          <?
          	//print_r($values);
          ?>
          <?
          	for($i = 0; $i < count($arr);$i++)
            {
            	$name_label = $arr[$i]['column_name'];
                $type_label = $arr[$i]['data_type'];
             ?>
          <tr style="text-align:center;" <?=($i%2) == 0 ? 'class="alt"' : ''?> >
            <td><?=$i?></td>
            <td><?=$name_label?></td>
            <td><?=$type_label?></td>
            <td><input type="checkbox" name="iddel[]" id="check<?=$i?>" <?=($values['values'][$i] == '1')?('checked="checked"'):''?>/></td>
            <td><?=$values['values'][$i]?></td>
          </tr>
          <?  
          	}
          	?>
        </thead>
      </table>
      <div class="extrabottom">
        <div class="bulkactions">
          <ul>
            <input type="hidden" name="id" value="<?=isset($_GET['id'])?$_GET['id']:''?>"/>
            <li>
              <input type="button" value="Tạo Values" class="btn" onclick="CheckCreate(); return false;"/>
            </li>
            <li>
              <input type="submit" value="submit" class="btn" />
            </li>
            <li>
              <input type="submit" value="Submit (Alternative)" class="btnalt" />
            </li>
          </ul>
        </div>
      </div>
      <?//=$plpage?>
      <div style="clear: both;"></div>
    </div>
  </form>
</div>
<script>
function ChangeAction(str){
	if(confirm("Are You Sure?"))
	{
		document.f.action = str;
		document.f.submit();
	}
}
function checkAll()
{
	n = <?=count($arr)?>;
	
	for(var i=0;i<<?=count($arr)?>;i++)
	{
		
		document.getElementById("check"+i).checked = true;
	}
	
}function checkAll2()
{
	n = <?=count($arr)?>;
	
	for(var i=0;i<<?=count($arr)?>;i++)
	{
		
		document.getElementById("check"+i).checked = false;
	}
	
}
function CheckCreate(){
	
	n = <?=count($arr)?>;
	tr = '';
	for(var i=0;i< n;i++)
	{		
		if(document.getElementById("check"+i).checked == true)
		{
			tr = tr + "1";
		}
		else
		{
			tr = tr + "0";
		}
	}
	var frmEdit = document.getElementById("frmEdit");
	frmEdit.values.value = tr;
}
</script> 
